package play.go.rule;

import static play.go.rule.Color.*;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

public class Eye extends Point {

    public static Collection<Eye> gets(int[][] grid) {
        Set<Eye> eyes = new HashSet<Eye>();
        int size = grid.length - 1;
        for (int x = 1; x < size; x++) {
            for (int y = 1; y < size; y++) {
                if (grid[y][x] == SPACE && grid[y - 1][x] != SPACE && grid[y][x - 1] != SPACE
                        && grid[y + 1][x] != SPACE && grid[y][x + 1] != SPACE) {
                    eyes.add(new Eye(x, y));
                }
            }
        }
        return eyes;
    }

    public Eye(int x, int y) {
        super(0, x, y);
    }
}
